MESSAGE(STATUS "Set Libimp sources")

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -EL -flax-vector-conversions")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EL -flax-vector-conversions -Wno-invalid-offsetof")

#Add core sources
FILE(GLOB_RECURSE CORE_SRCS "core/*.c" "core/*.h")

#Add video sources
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/icommon/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/hwicodec/src/protocol/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/i264e/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/hwicodec/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/ijpege/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/ijpegd/include)
#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/i265e/include)
#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/video/icodec/i265e/comkit/include)

FILE(GLOB_RECURSE ENCODER_SRCS "video/*.h")
SET(ENCODER_SRCS ${ENCODER_SRCS}
	video/icodec/icommon/src/mc.c
	video/icodec/icommon/src/kmmc.c
	video/icodec/icommon/src/resize_c.c
	video/icodec/icommon/src/common.c
	video/icodec/icommon/src/embedwm.c
	video/icodec/icommon/src/debug.c
	video/icodec/hwicodec/src/common/soc.c
	video/icodec/hwicodec/src/common/private_tlb.c
	video/icodec/hwicodec/src/common/h264e.c
	#video/icodec/hwicodec/src/common/h265e.c
	video/icodec/hwicodec/src/common/reqid.c
	video/icodec/hwicodec/src/common/jpege.c
	video/icodec/hwicodec/src/common/jpegd.c
	video/icodec/hwicodec/src/common/common.c
	video/icodec/hwicodec/src/codec/pf.c
	video/icodec/hwicodec/src/codec/codec.c
	#video/icodec/hwicodec/src/protocol/h264/soc_m200/h264e/jzm_i264_enc.c
	#video/icodec/hwicodec/src/protocol/h264/soc_m200/h264e/encode.c
	#video/icodec/hwicodec/src/protocol/h264/soc_m200/h264e/dump.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t10/h264e/jzm_i264_enc.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t10/h264e/encode.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t10/h264e/dump.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t20/h264e/jzm_i264_enc.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t20/h264e/ncu_reg.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t20/h264e/encode.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t20/h264e/dump.c
	video/icodec/hwicodec/src/protocol/h264/soc_t23/h264e/jzm_i264_enc.c
	video/icodec/hwicodec/src/protocol/h264/soc_t23/h264e/encode.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t21/h264e/dump.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t30/h264e/jzm_i264_enc.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t30/h264e/encode.c
	#video/icodec/hwicodec/src/protocol/h264/soc_t30/h264e/dump.c
	#video/icodec/hwicodec/src/protocol/jpeg/soc_t10/jpegd/jzm_jpeg_dec.c
	#video/icodec/hwicodec/src/protocol/jpeg/soc_t10/jpegd/decode.c
	#video/icodec/hwicodec/src/protocol/jpeg/soc_t10/jpege/jzm_jpeg_enc.c
	#video/icodec/hwicodec/src/protocol/jpeg/soc_t10/jpege/encode.c
	#video/icodec/hwicodec/src/protocol/jpeg/soc_t10/jpege/dump.c
	video/icodec/hwicodec/src/protocol/jpeg/soc_t23/jpegd/jzm_jpeg_dec.c
	video/icodec/hwicodec/src/protocol/jpeg/soc_t23/jpegd/decode.c
	video/icodec/hwicodec/src/protocol/jpeg/soc_t23/jpege/jzm_jpeg_enc.c
	video/icodec/hwicodec/src/protocol/jpeg/soc_t23/jpege/encode.c
	#video/icodec/hwicodec/src/protocol/jpeg/soc_t20/jpege/dump.c
	#video/icodec/hwicodec/src/protocol/h265/soc_t30/h265e/jzm_i265_enc.c
	#video/icodec/hwicodec/src/protocol/h265/soc_t30/h265e/encode.c
	#video/icodec/hwicodec/src/protocol/h265/soc_t30/h265e/dump.c
	video/icodec/ijpegd/src/common/set.c
	video/icodec/ijpegd/src/common/common.c
	video/icodec/ijpegd/src/decode/iicodec.c
	video/icodec/ijpegd/src/decode/decode.c
	video/icodec/i264e/src/common/cabac.c
	video/icodec/i264e/src/common/osdep.c
	video/icodec/i264e/src/common/pixel.c
	#video/icodec/i264e/src/common/dump.c
	video/icodec/i264e/src/common/set.c
	video/icodec/i264e/src/common/threadpool.c
	video/icodec/i264e/src/common/common.c
	video/icodec/i264e/src/common/bitstream.c
	video/icodec/i264e/src/encode/frame.c
	video/icodec/i264e/src/encode/rdindex.c
	video/icodec/i264e/src/encode/reconfig.c
	video/icodec/i264e/src/encode/encode.c
	video/icodec/i264e/src/encode/ratecontrol.c
	video/icodec/i264e/src/encode/iicodec.c
	video/icodec/ijpege/src/common/set.c
	video/icodec/ijpege/src/common/common.c
	video/icodec/ijpege/src/encode/frame.c
	video/icodec/ijpege/src/encode/encode.c
	video/icodec/ijpege/src/encode/iicodec.c
	video/icodec/ijpege/src/encode/reconfig.c
	#video/icodec/i265e/src/encode/Encode.cpp
	#video/icodec/i265e/src/encode/I265e.cpp
	#video/icodec/i265e/src/encode/Codec.cpp
	#video/icodec/i265e/src/encode/DecTypeAndRD.cpp
	#video/icodec/i265e/src/encode/EncodeCommon.cpp
	#video/icodec/i265e/src/encode/EncodeFrame.cpp
	#video/icodec/i265e/src/encode/Ratectrl.cpp
	#video/icodec/i265e/src/encode/Reconfig.cpp
	#video/icodec/i265e/src/encode/Stat.cpp
	#video/icodec/i265e/src/encode/Frame.cpp
	#video/icodec/i265e/src/common/Common.cpp
	#video/icodec/i265e/src/common/Constants.cpp
	#video/icodec/i265e/src/common/Bitstream.cpp
	#video/icodec/i265e/src/common/Entropy.cpp
	#video/icodec/i265e/src/common/Scalinglist.cpp
	#video/icodec/i265e/src/common/Slice.cpp
	#video/icodec/i265e/src/common/Primitives.cpp
	#video/icodec/i265e/src/common/Dct.cpp
	#video/icodec/i265e/src/common/Intrapred.cpp
	#video/icodec/i265e/src/common/Ipfilter.cpp
	#video/icodec/i265e/src/common/Loopfilter.cpp
	#video/icodec/i265e/src/common/Pixel.cpp
	#video/icodec/i265e/src/common/Sae.cpp
	#video/icodec/i265e/src/common/Nal.cpp
	#video/icodec/i265e/src/common/Sei.cpp
	#video/icodec/i265e/src/common/Level.cpp
	#video/icodec/i265e/comkit/src/VideoInputDev.cpp
	#video/icodec/i265e/comkit/src/VideoInputFileI420.cpp
	#video/icodec/i265e/comkit/src/VideoInputFileNv12.cpp
	#video/icodec/i265e/comkit/src/VideoInputFileT420.cpp
	#video/icodec/i265e/comkit/src/VideoInputThread.cpp
	#video/icodec/i265e/comkit/src/VideoOutputFile.cpp
	#video/icodec/i265e/comkit/src/FrameRateCtrl.cpp
	#video/icodec/i265e/comkit/src/FrameSizeCtrl.cpp
	#video/icodec/i265e/comkit/src/WorkBond.cpp
	#video/icodec/i265e/comkit/src/WorkCommon.cpp
	#video/icodec/i265e/comkit/src/WorkList.cpp
	#video/icodec/i265e/comkit/src/WorkTask.cpp
	#video/icodec/i265e/comkit/src/WorkThread.cpp
	video/imp_video_common.c
	video/imp_encoder.c
	video/imp_decoder.c
	video/imp_mempool.c
	#	video/ncu_params.c
#For Zeratul
	video/bootup_timer.c
)

#Add isp sources
FILE(GLOB ISP_SRCS "isp/*.c" "isp/*.h")

#Add base sources
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/base)
FILE(GLOB_RECURSE BASE_SRCS "base/*.c"  "base/*.h")

#Add framesource sources
FILE(GLOB_RECURSE FRAMESOURCE_SRCS "framesource/framesource_tseries.c"  "framesource/*.h")

#FILE(GLOB_RECURSE NCUFUNC_SRCS
#	"isp/ncufunc/ncudbgserver.c"
#	"isp/ncufunc/ncu_ctrl.c"
#	"isp/ncufunc/ncu_func.c"
#	"isp/ncufunc/ncu_hal.c"
#	"isp/ncufunc/ncu.c"
#	"isp/ncufunc/ncubuf.c"
#	"isp/ncufunc/ncureg.c"
#	)

#Add audio sources
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/codecs/g711-code)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/codecs/g726-code)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/codecs/adpcm-code)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/profiles)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/agc)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/ns)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/aec)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/hpf)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/hs)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/include)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/include/webrtc_audio_processing)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/howling-suppression/include)

FILE(GLOB_RECURSE AUDIO_SRCS
    "audio/profiles/*.c"
    "audio/profiles/*.h"
    "audio/codecs/g711-code/*.c"
    "audio/codecs/g711-code/*.h"
    "audio/codecs/g726-code/*.c"
    "audio/codecs/g726-code/*.h"
    "audio/codecs/adpcm-code/*.c"
    "audio/codecs/adpcm-code/*.h"
    "audio/audioProcess/agc/*.h"
    "audio/audioProcess/ns/*.h"
    "audio/audioProcess/aec/*.h"
    "audio/audioProcess/hpf/*.h"
	"audio/audioProcess/hs/*.h"
	"audio/audioProcess/drc/*.h"
)
SET(AUDIO_SRCS ${AUDIO_SRCS}
	audio/ai.c
	audio/ao.c
	audio/abuf.c
	audio/abuf.h
	audio/aenc.c
	audio/adec.c
	#audio/dmic.c
	#audio/dmic.h
	audio/audio_common.c
	audio/audio_common.h
    audio/audio_process.c
    audio/audio_process.h
    audio/audioProcess/agc/audio_agc.h
    audio/audioProcess/ns/audio_ns.h
    audio/audioProcess/aec/audio_aec.h
    audio/audioProcess/hpf/audio_hpf.h
	audio/audioProcess/aec/profiles/profiles_management.c
	audio/audioProcess/aec/profiles/profiles_management.h
	audio/audioProcess/hs/audio_hs.h
	audio/audioProcess/drc/audio_drc.h
)

SET(DSYSTEM_SRCS
    dsystem/funcs.c
    dsystem/shm.c
    dsystem/shm.h
)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/agc)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/ns)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/aec)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/audio/audioProcess/hs)

FILE(GLOB_RECURSE AUDIO_PROCESS_SRCS
	audio/audioProcess/agc/*.cpp
	audio/audioProcess/agc/*.h
	audio/audioProcess/ns/*.cpp
	audio/audioProcess/ns/*.h
	audio/audioProcess/aec/*.cpp
	audio/audioProcess/aec/*.h
	audio/audioProcess/aec/webrtc_aec.cpp
	audio/audioProcess/aec/webrtc_aec.h
	audio/audioProcess/hpf/*.cpp
	audio/audioProcess/hpf/*.h
	audio/audioProcess/aec/profiles/*.c
	audio/audioProcess/aec/profiles/*.h
	audio/audioProcess/hs/*.cpp
	audio/audioProcess/hs/*.h
	audio/audioProcess/drc/*.cpp
	audio/audioProcess/drc/*.h
)
SET(AUDIO_PROCESS_SRCS
	audio/audioProcess/agc/audio_agc.cpp
	audio/audioProcess/agc/audio_agc.h
	audio/audioProcess/ns/audio_ns.cpp
	audio/audioProcess/ns/audio_ns.h
	audio/audioProcess/aec/audio_aec.cpp
	audio/audioProcess/aec/audio_aec.h
	audio/audioProcess/aec/webrtc_aec.cpp
	audio/audioProcess/aec/webrtc_aec.h
	audio/audioProcess/hpf/audio_hpf.cpp
	audio/audioProcess/hpf/audio_hpf.h
	audio/audioProcess/aec/profiles/profiles_management.c
	audio/audioProcess/aec/profiles/profiles_management.h
	audio/audioProcess/hs/audio_hs.cpp
	audio/audioProcess/hs/audio_hs.h
	audio/audioProcess/drc/audio_drc.cpp
	audio/audioProcess/drc/audio_drc.h
	audio/audioProcess/drc/src/drc_core.c
	audio/audioProcess/drc/src/drc_core.h
	audio/audioProcess/drc/src/dynamic_range_compression.c
	audio/audioProcess/drc/src/fft4g.c
	audio/audioProcess/drc/src/fft4g.h
	audio/audioProcess/drc/src/windows_private.h
	audio/audioProcess/drc/src/include/dynamic_range_compression.h
)

#Add osd sources
FILE(GLOB_RECURSE OSD_SRCS "osd/*.c" "osd/*.h")

#Add ivs sources
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/ivs/ivs_move/include)
SET(IVS_SRCS
    ivs/ivs.c
    ivs/ivs_move/move_ivs.c
    ivs/ivs_move/src/ivs_move.c
    ivs/ivs_move/src/filter.c
    ivs/ivs_move/src/move_detect.c
)

#Add base ivs sources
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/ivs/ivs_base_move/include)
SET(BASE_IVS_SRCS
	ivs/ivs_base_move/base_move_ivs.c
	ivs/ivs_base_move/src/ivs_base_move.c
	ivs/ivs_base_move/src/sad.c
	ivs/ivs_base_move/src/MergeBaseMove.c
)

#Add protobuf-c sources
#SET(PBC_SRCS
#    pbc/NCU_Params.proto-c.pb-c.c
#    pbc/protobuf-c.c
#)

#Add fb sources
SET(FB_SRCS
    fb/fb.c
)

#Add emulator sources
FILE(GLOB_RECURSE EMU_SRCS "emulator/*.c" "emulator/*.h")

#Set sources
SET(LIBIMP_SRCS ${CORE_SRCS} ${BASE_SRCS} ${ENCODER_SRCS} ${ISP_SRCS}
	${FRAMESOURCE_SRCS} ${NCUFUNC_SRCS}
	${AUDIO_SRCS} ${OSD_SRCS} ${IVS_SRCS} ${BASE_IVS_SRCS} ${ALGO_SRCS} ${FB_SRCS}
	${DSYSTEM_SRCS} ${SYS_WRAP_SRCS} ${PBC_SRCS})

#set libaudioProcess sources
SET(LIBAUDIOPROCESS_SRCS ${AUDIO_PROCESS_SRCS})

#Add external objs
SET(EXT_STATIC_GLIBC_OBJS
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_nofpic.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_nofpic_t20.o
    ${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_nofpic_t21.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_nofpic_t30.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_nofpic_t30_radix.o
    #${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/obj/glibc/webrtc_static.o
)

SET(EXT_SHARED_GLIBC_OBJS
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_fpic.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_fpic_t20.o
    ${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_fpic_t21.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_fpic_t30.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/glibc/jzm_enc_api_fpic_t30_radix.o
    #${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/obj/glibc/webrtc_shared.o
)

SET(EXT_STATIC_UCLIBC_OBJS
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_nofpic.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_nofpic_t20.o
    ${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_nofpic_t21.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_nofpic_t30.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_nofpic_t30_radix.o
    #${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/obj/uclibc/webrtc_static.o
)

SET(EXT_SHARED_UCLIBC_OBJS
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_fpic.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_fpic_t20.o
    ${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_fpic_t21.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_fpic_t30.o
	#${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/vpu/obj/uclibc/jzm_enc_api_fpic_t30_radix.o
    #${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/obj/uclibc/webrtc_shared.o
)

SET(EXT_SHARED_GLIBC_AUDIO_OBJS
    ${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/obj/glibc/webrtc_shared.o
	${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/howling-suppression/obj/glibc/howling_suppression_shared.o
)

SET(EXT_SHARED_UCLIBC_AUDIO_OBJS
    ${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/webrtc/obj/uclibc/webrtc_shared.o
	${PROJECT_SOURCE_DIR}/external/${EXT_LIB_DIR}/howling-suppression/obj/uclibc/howling_suppression_shared.o
)
